#! /bin/bash
source /etc/profile
if [ -n "$1" ] ;then
do_date=$1
else
do_date=`date -d "-1 day" +%F`
fi

sql="
insert overwrite table ads.ads_member_continue_active_cnt
partition(dt='$do_date')
(
select count(device_id) continue_active_cnt from (select device_id, count(1) cnt from (select device_id,dt from dws.dws_member_start_day where dt between date_sub('$do_date', 7) and '$do_date')tmp1 group by device_id having cnt >= 3)tmp1);
"
hive -e "$sql"
